1
/***************************************** Module Header *****************************\
2 * Module Name: MyControl.cs
3 * Project: CSVSPackageStatusBar
4 * Copyright (c) Microsoft Corporation.
6 * In this sample, we will demo:
7 * 1. Write highlighted text in feedback region
8 * 2. Read text from feedback region
9 * 3. Show progress bar in status bar
10 * 4. Show animation in the status bar
11 * 5. Write row, column and char to designer region
13 * This source is subject to the Microsoft Public License.
14 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
15 * All other rights reserved.
18 * * 02/26/2010 04:35 PM Hongye Sun Created
19 \*************************************************************************************/
21 using System
.Security
.Permissions
;
22 using System
.Windows
.Forms
;
23 using Microsoft
.VisualStudio
.Shell
.Interop
;
25 namespace Company
.CSVSPackageStatusBar
28 /// Summary description for MyControl.
30 public partial class MyControl
: UserControl
34 InitializeComponent();
37 public IVsStatusbar SvcStatusBar { get; set; }
40 /// Let this control process the mnemonics.
42 [UIPermission(SecurityAction
.LinkDemand
, Window
= UIPermissionWindow
.AllWindows
)]
43 protected override bool ProcessDialogChar(char charCode
)
45 // If we're the top-level form or control, we need to do the mnemonic handling
46 if (charCode
!= ' ' && ProcessMnemonic(charCode
))
50 return base.ProcessDialogChar(charCode
);
54 /// Enable the IME status handling for this control.
56 protected override bool CanEnableIme
64 private void btnWriteFeedback_Click(object sender
, System
.EventArgs e
)
66 // Checks to see if the status bar is frozen
67 // by calling the IsFrozen method.
69 SvcStatusBar
.IsFrozen(out frozen
);
72 // SetColorText only displays white text on a
73 // dark blue background.
74 SvcStatusBar
.SetColorText("Here's some highlighted text", 0, 0);
75 System
.Windows
.Forms
.MessageBox
.Show("Pause");
76 SvcStatusBar
.SetText("Done");
80 private void btnReadFeedback_Click(object sender
, System
.EventArgs e
)
82 // Retrieve the status bar text.
84 SvcStatusBar
.GetText(out text
);
85 System
.Windows
.Forms
.MessageBox
.Show(text
);
87 // Clear the status bar text.
88 SvcStatusBar
.FreezeOutput(0);
92 private void btnShowProgressBar_Click(object sender
, System
.EventArgs e
)
95 string label
= "Progress bar label...";
97 // Initialize the progress bar.
98 SvcStatusBar
.Progress(ref cookie
, 1, "", 0, 0);
100 for (uint i
= 0, total
= 100; i
<= total
; i
++)
102 // Display incremental progress.
103 SvcStatusBar
.Progress(ref cookie
, 1, label
, i
, total
);
104 System
.Threading
.Thread
.Sleep(10);
107 // Clear the progress bar.
108 SvcStatusBar
.Progress(ref cookie
, 0, "", 0, 0);
111 private void btnShowAnimation_Click(object sender
, System
.EventArgs e
)
114 (short)Microsoft
.VisualStudio
.Shell
.Interop
.Constants
.SBAI_General
;
116 // Display the animated Visual Studio icon in the Animation region.
117 // Start the animation by calling the Animation method of the status bar.
118 // Pass in 1 as the value of the first parameter, and a reference to an
119 // animated icon as the value of the second parameter.
120 SvcStatusBar
.Animation(1, ref icon
);
122 System
.Windows
.Forms
.MessageBox
.Show(
123 "Click OK to end status bar animation.");
125 // Stop the animation by calling the Animation method of the status bar.
126 // Pass in 0 as the value of the first parameter, and a reference to the
127 // animated icon as the value of the second parameter.
128 SvcStatusBar
.Animation(0, ref icon
);
131 private void btnUpdateDesignerRegion_Click(object sender
, System
.EventArgs e
)
133 // Set insert/overstrike mode.
134 object mode
= 1; // Insert mode
135 SvcStatusBar
.SetInsMode(ref mode
);
137 // Display Ln ## Col ## Ch ## information.
138 object ln
= "##", col
= "##", ch
= "##";
139 SvcStatusBar
.SetLineColChar(ref ln
, ref col
, ref ch
);